<template>
  <div id="one-box">
    <UserPageLayout :userDetail="userDetail" @init="init" />
    <div class="screen">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import { userDetail } from "@/api";
import UserPageLayout from "@/components/userPageLayout";
import {mapActions} from 'vuex'
export default {
  name: "userpage",
  components: { UserPageLayout },
  data() {
    return {
      userDetail: {
        profile: {},
      },
    };
  },
  created() {
    this.init();
  },
  watch: {
    "$route.query.id"(newValue, oldValue) {
      this.init();
    },
  },
  methods: {
    ...mapActions("user",["SET_CHANGE_USER_SINGER_DETAILS"]),
    init() {
      this.getUserDetails();
    },
    getUserDetails() {
      userDetail({ uid: this.$route.query.id }).then((data) => {
        this.userDetail = data;
        this.SET_CHANGE_USER_SINGER_DETAILS(data)
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>